#!/usr/bin/env python

'''
    Christopher Williams requested to read Studio submissions.

    Because of a larg number of submissions, we only assign 3 readers per
    poster.  This was done by mapping the posters to the chair, who will ignore
    them.
'''

Users = {}
Requests = {
    # Studio chair wants more studio submissions
    # These are submissions which don't have many reviewers
    'general_74':'Christopher Williams',
    'general_93':'Christopher Williams',
    'general_171':'Christopher Williams',
    'general_406':'Christopher Williams',
    'general_460':'Christopher Williams',
    # These are some other studio submissions
    'general_413':'Christopher Williams',
    'general_443':'Christopher Williams',
    'general_758':'Christopher Williams',
    'general_767':'Christopher Williams',
    # Leave some unassigned to map based on expertise

    # We want posters to only receive 3 reviews, so assign them to the chair
    'general_16':'Mark Elendt',
    'general_17':'Mark Elendt',
    'general_19':'Mark Elendt',
    'general_29':'Mark Elendt',
    'general_36':'Mark Elendt',
    'general_42':'Mark Elendt',
    'general_44':'Mark Elendt',
    'general_45':'Mark Elendt',
    'general_79':'Mark Elendt',
    'general_106':'Mark Elendt',
    'general_119':'Mark Elendt',
    'general_120':'Mark Elendt',
    'general_145':'Mark Elendt',
    'general_155':'Mark Elendt',
    'general_156':'Mark Elendt',
    'general_158':'Mark Elendt',
    'general_178':'Mark Elendt',
    'general_179':'Mark Elendt',
    'general_191':'Mark Elendt',
    'general_193':'Mark Elendt',
    'general_201':'Mark Elendt',
    'general_204':'Mark Elendt',
    'general_219':'Mark Elendt',
    'general_243':'Mark Elendt',
    'general_272':'Mark Elendt',
    'general_273':'Mark Elendt',
    'general_303':'Mark Elendt',
    'general_304':'Mark Elendt',
    'general_305':'Mark Elendt',
    'general_312':'Mark Elendt',
    'general_313':'Mark Elendt',
    'general_317':'Mark Elendt',
    'general_320':'Mark Elendt',
    'general_326':'Mark Elendt',
    'general_337':'Mark Elendt',
    'general_338':'Mark Elendt',
    'general_339':'Mark Elendt',
    'general_343':'Mark Elendt',
    'general_344':'Mark Elendt',
    'general_357':'Mark Elendt',
    'general_369':'Mark Elendt',
    'general_370':'Mark Elendt',
    'general_376':'Mark Elendt',
    'general_396':'Mark Elendt',
    'general_401':'Mark Elendt',
    'general_405':'Mark Elendt',
    'general_411':'Mark Elendt',
    'general_421':'Mark Elendt',
    'general_424':'Mark Elendt',
    'general_428':'Mark Elendt',
    'general_434':'Mark Elendt',
    'general_435':'Mark Elendt',
    'general_442':'Mark Elendt',
    'general_464':'Mark Elendt',
    'general_469':'Mark Elendt',
    'general_471':'Mark Elendt',
    'general_474':'Mark Elendt',
    'general_476':'Mark Elendt',
    'general_482':'Mark Elendt',
    'general_496':'Mark Elendt',
    'general_506':'Mark Elendt',
    'general_507':'Mark Elendt',
    'general_514':'Mark Elendt',
    'general_515':'Mark Elendt',
    'general_523':'Mark Elendt',
    'general_524':'Mark Elendt',
    'general_525':'Mark Elendt',
    'general_536':'Mark Elendt',
    'general_539':'Mark Elendt',
    'general_567':'Mark Elendt',
    'general_568':'Mark Elendt',
    'general_580':'Mark Elendt',
    'general_582':'Mark Elendt',
    'general_584':'Mark Elendt',
    'general_590':'Mark Elendt',
    'general_598':'Mark Elendt',
    'general_602':'Mark Elendt',
    'general_605':'Mark Elendt',
    'general_607':'Mark Elendt',
    'general_616':'Mark Elendt',
    'general_621':'Mark Elendt',
    'general_622':'Mark Elendt',
    'general_637':'Mark Elendt',
    'general_646':'Mark Elendt',
    'general_649':'Mark Elendt',
    'general_651':'Mark Elendt',
    'general_654':'Mark Elendt',
    'general_656':'Mark Elendt',
    'general_659':'Mark Elendt',
    'general_661':'Mark Elendt',
    'general_663':'Mark Elendt',
    'general_664':'Mark Elendt',
    'general_667':'Mark Elendt',
    'general_682':'Mark Elendt',
    'general_685':'Mark Elendt',
    'general_687':'Mark Elendt',
    'general_691':'Mark Elendt',
    'general_692':'Mark Elendt',
    'general_694':'Mark Elendt',
    'general_696':'Mark Elendt',
    'general_697':'Mark Elendt',
    'general_702':'Mark Elendt',
    'general_713':'Mark Elendt',
    'general_715':'Mark Elendt',
    'general_720':'Mark Elendt',
    'general_723':'Mark Elendt',
    'general_731':'Mark Elendt',
    'general_732':'Mark Elendt',
    'general_760':'Mark Elendt',
    'general_766':'Mark Elendt',
    'general_776':'Mark Elendt',
    'general_779':'Mark Elendt',
    'general_789':'Mark Elendt',
    'general_790':'Mark Elendt',
    'general_807':'Mark Elendt',
}

def mapUsers():
    for l in open('map-reviewers.txt', 'r').readlines():
        args = l.split()
        name = ' '.join(args[1:])
        Users[name] = args[0]

def adjustPosters():
    for l in open('map-submissions.txt', 'r').readlines():
        args = l.split()
        if len(args) > 1:
            name = args[1]
            if Requests.has_key(name):
                user = Requests[name]
                if Users.has_key(user):
                    id = int(name.replace('general_', ''))
                    Requests[name] = (id, args[0], Users[user])
                else:
                    print '--- Missing user: %s ---', user

mapUsers()
adjustPosters()
plist = []
for p in Requests:
    plist.append(Requests[p])
plist.sort()
fp = open('map-request.txt', 'w')
for req in plist:
    fp.write('%s %s\n' % (req[1], req[2]))
